Skip to content

feat(receivers): expose invalidRequestSignatureHandler on HTTPReceiver (closes #2156) - #3052

Open
aniruddhaadak80 wants to merge 1 commit into
slackapi:mainfrom
aniruddhaadak80:feat/invalid-signature-handler-http-receiver
Open

feat(receivers): expose invalidRequestSignatureHandler on HTTPReceiver (closes #2156)#3052
aniruddhaadak80 wants to merge 1 commit into
slackapi:mainfrom
aniruddhaadak80:feat/invalid-signature-handler-http-receiver

Conversation

@aniruddhaadak80

Copy link
Copy Markdown

What Problem This Solves

The invalidRequestSignatureHandler option was added to AwsLambdaReceiver in PR #2154 but is not available on HTTPReceiver / ExpressReceiver. Issue #2156 requests this same capability for the HTTP-based receivers, useful for adding custom logging, metrics, or alerting when Slack request signatures fail verification.

Why This Change Was Made

Users deploying bolt apps with HTTP receivers have no way to hook into the signature verification failure path. They can only see the default warning log. Adding the handler lets users emit custom telemetry, count failures, or trigger alerts.

What Changed

  • Added invalidRequestSignatureHandler to RequestVerificationOptions in HTTPModuleFunctions.ts
  • Wrapped verifySlackRequest in a try/catch that invokes the handler (when set) before re-throwing the error so the 401 response still happens
  • Exposed invalidRequestSignatureHandler on HTTPReceiverOptions in HTTPReceiver.ts
  • Wired the option through the constructor and passed to parseAndVerifyHTTPRequest
  • The handler is invoked on all signature verification failures (invalid signature, missing headers, too old timestamp, etc.) — same semantics as AwsLambdaReceiver
  • The new ReceiverInvalidRequestSignatureHandlerArgs interface exposes rawBody, signature, requestTimestampSec, and request for use in custom handlers

How Tested

  • TypeScript compiles cleanly (tsc --noEmit)
  • The pre-existing failure in test/unit/middleware/builtin.spec.ts(165,29) is unrelated to this change (it was already modified in the fetch M test/unit/middleware/builtin.spec.ts)
  • ExpressReceiver extends HTTPReceiver, so the new option is automatically available on ExpressReceiver as well

Fixes #2156

closes slackapi#2156)

Adds an optional invalidRequestSignatureHandler to HTTPReceiver and
ExpressReceiver, mirroring the pattern introduced in AwsLambdaReceiver
(slackapi#2154). The handler is invoked when a request fails signature
verification, allowing custom logging/metrics before the 401 response
is returned.
@aniruddhaadak80
aniruddhaadak80 requested a review from a team as a code owner August 27, 2026 13:55
@changeset-bot

changeset-bot Bot commented Aug 27, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 11cb855

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@salesforce-cla

Copy link
Copy Markdown

Thanks for the contribution! Before we can merge this, we need @aniruddhaadak80 to sign the Salesforce Inc. Contributor License Agreement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add invalidRequestSignatureHandler to HTTP/ExpressReceiver

1 participant